package level.editor.mediator;

import java.util.HashMap;

import level.editor.command.Command;

/*
 * Handles interaction between different modules. Registers all the modules into
 * a hash table, and uses it to pass Commands between modules. Ideally, it
 * should have no knowledge of what is contained within Commands except for the
 * destination.
 */

public class Mediator
{
	private static final int CAPACITY = 10;
	private static final int LOADFACTOR = 1;

	private HashMap<String, Module> map;

	public Mediator()
	{
		map = new HashMap<String, Module>(CAPACITY, LOADFACTOR);
	}

	public void add(String name, Module module)
	{
		map.put(name, module);
	}

	public void pushUpCommand(Command command)
	{
		pushDownCommand(command);
	}
	
	private void pushDownCommand(Command command)
	{
		map.get(command.getDestination()).pushDownCommand(command);
	}

}
